package com.netease.nie.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.netease.nie.common.CommonService;
import com.netease.nie.dao.OrdersTraceDao;
import com.netease.nie.dto.OrdersTraceDto;
import com.netease.nie.model.OrdersTrace;

@Service
public class OrdersTraceServiceImpl extends CommonService implements OrdersTraceService {
	
	@Autowired
	private OrdersTraceDao ordersTraceDao;

	public List<OrdersTraceDto> queryOrdersTraceListByOrdersId(long orderId){		
		List<OrdersTrace> ordersTraceList = ordersTraceDao.queryOrdersTraceListByOrdersId(orderId);
		List<OrdersTraceDto> ordersTraceDtoList = generateOrdersTraceDtos(ordersTraceList);
		return ordersTraceDtoList;
	}
	
	public int insertOrdersTrace(OrdersTrace ordersTrace) {
		try {
			ordersTraceDao.insertOrdersTrace(ordersTrace);
		} catch (Exception e) {
			return 0;
		}
		return 1;
	}

	public List<OrdersTraceDto> queryCurrentStatusOrdersTraceDtosByOrderIds(
			List<Long> orderIds) {
		List<OrdersTrace> ordersTraceList = ordersTraceDao.queryCurrentStatusOrdersTracesByOrderIds(orderIds);
		List<OrdersTraceDto> ordersTraceDtoList = generateOrdersTraceDtos(ordersTraceList);
		return ordersTraceDtoList;
	}
	
}
